#ifndef __ENCODER__
#define __ENCODER__

#ifdef __cplusplus
extern "C"
{
#endif
#ifdef CH32
#include "debug.h"
#endif
#ifdef STM32
#include "tim.h"
#endif
#include "math.h"
#ifdef __cplusplus
}
#endif
#ifdef AT32
#include "at_init.hpp"
#endif
#include "Time.hpp"
class Encoder
{
private:
    uint16_t ENCOEDR_CPR;
    float DEGTrans;
    const float PI = 3.141592653f;
    float engle_offset;
    volatile uint8_t F_MODE = 0;
    volatile float encoder_ = 0;
    volatile float speed_ = 0;
    float pos;
    float last_pos;
    float time;
    float last_time;
public:
    Encoder(uint16_t value);
    ~Encoder();
    void InitEncoder(uint16_t value);
    int32_t getRawEncoder();
    int32_t getRawEncoder(bool);
    float getDegEncoder();
    void setMode(uint8_t setvalue);
    void setSpeed(float speed);
    float getEngle_offset();
    void setEngle_offset(float value);
    float getRotspeed();
};



#endif